package com.bishe.app.modules.groupuser.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.*;
import java.util.stream.Collectors;

/**
 * Created : 2024/4/1, 21:01
 *
 * @author : jeffrey.hu
 **/
@AllArgsConstructor
@Getter
public enum GroupUserPosition {

    DEFAULT(0,0,"默认"),

    // 店铺SHOP 职位
    LEADER(1,1,"店长"),
    EMPLOYEE(1,2,"员工"),


    // 市场部
    DU_DAO(2,100,"督导"),
    ZONG_JIAN(2,101,"销售总监"),
    CHEN_LIE_SHI(2,102,"陈列师"),
    CAI_GOU(2,103,"采购"),
    HR(2,104,"人事"),
    CHU_NA(2,105,"出纳"),
    SHICHANG_JINGLI(2,106,"市场经理"),
    ZONG_JING_LI(2,107,"总经理"),
    ZONG_JING_LI_ZHU_LI(2,108,"总经理助理"),

    // 后勤部
    CAIWU_ZONGJIAN(3,201,"财务总监"),
    KUAI_JI(3,202,"会计"),
    SHOU_HUO_YUAN(3,203,"收货员"),
    HOU_QIN_ZONG_GUAN(3,204,"后勤总管"),
    LI_HUO_YUAN_LIHUO(3,205,"理货员-理货"),
    LI_HUO_YUAN_CHEBIAO(3,206,"理货员-车标"),
    SONG_HUO_SIJI(3,207,"送货司机"),


    // 鞋店
    XIEDIAN_LEADER(4,301,"鞋店店长"),
    XIEDIAN_EMPLOYEE(4,302,"鞋店员工"),
    ;






    private Integer groupType;

    private Integer code;

    private String desc;

    public static List<Integer> getPositions(Integer groupType){
        return Arrays.stream(values())
                .filter(x->x.getGroupType().equals(groupType))
                .map(x->x.getCode())
                .collect(Collectors.toList());
    }

     public static List<Map<String,Object>> getPositionMap(Integer groupType){
         List<GroupUserPosition> collectList = Arrays.stream(values())
                 .filter(x -> x.getGroupType().equals(groupType))
                 .collect(Collectors.toList());

         List<Map<String,Object>> lists = new ArrayList<>();
         for (GroupUserPosition groupUserPosition : collectList) {
             Map<String,Object> map = new HashMap<>();
             map.put("id",groupUserPosition.getCode());
             map.put("name",groupUserPosition.getDesc());

             lists.add(map);
         }

         return lists;
     }


    public static GroupUserPosition ofCode(Integer code) {
        for (GroupUserPosition value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }

}
